using System.Collections.Generic;
using UnityEngine;
using Sirenix.OdinInspector;
using TMPro;
using Pangoo.Core.Common;
using Pangoo.Core.Services;
using LitJson;
using Pangoo.Common;
using UnityEngine.UI;
using Pangoo;
using Pangoo.Core.VisualScripting;

namespace CardCombine
{
    [Category("卡牌合成/游戏UI")]
    public class UICardCombinePanel : UIPanel
    {

        public UISideEffectParams ParamsRaw = new UISideEffectParams();

        protected override IParams Params => ParamsRaw;

        public TextMeshProUGUI m_Text;

        public TextMeshProUGUI m_NameText;

        public TextMeshProUGUI m_DescText;


        public TextMeshProUGUI m_CombineTitle;

        public TextMeshProUGUI m_CombineText;

        public RawImage m_bg_JianJie;

        public RawImage m_bg_HeCheng;

        public MainService Main
        {
            get
            {
                return PanelData.Main;
            }
        }



        Camera MainCamera { get; set; }




        [ShowInInspector]
        public CaseContent ShowContent;


        public bool IsShowingCase;



        public float Distance = 0.2f;


        public RectTransform TargetRect;
        public RectTransform CluesListRect;


        Canvas CurrentCanvas;
        RectTransform CanvasRectTransform;

        public GameObject CluePrefab;

        public float SelectDistanceDelta = 0.01f;

        protected override void OnOpen(object userData)
        {
            base.OnOpen(userData);

            m_Text = GetComponentInChildren<TextMeshProUGUI>();
            m_NameText = transform.Find("Name").GetComponent<TextMeshProUGUI>();
            m_DescText = transform.Find("Desc").GetComponent<TextMeshProUGUI>();
            m_CombineTitle = transform.Find("CombineTitle").GetComponent<TextMeshProUGUI>();
            m_CombineText = transform.Find("CombineDesc").GetComponent<TextMeshProUGUI>();
            m_bg_HeCheng = transform.Find("bg_HeCheng").GetComponent<RawImage>();
            m_bg_JianJie = transform.Find("bg_JianJie").GetComponent<RawImage>();



            MainCamera = GameObject.FindWithTag("MainCamera")?.GetComponent<Camera>();
            CurrentCanvas = this.GetComponentInParent<Canvas>();
            CanvasRectTransform = CurrentCanvas?.GetComponent<RectTransform>();


            m_Text?.gameObject.SetActive(false);
            m_NameText?.gameObject.SetActive(false);
            m_DescText?.gameObject.SetActive(false);
            m_CombineTitle?.gameObject.SetActive(false);
            m_CombineText?.gameObject.SetActive(false);



        }

        public void ShowTitle(string title)
        {
            m_NameText.text = title;
            m_NameText.gameObject.SetActive(true);
            m_bg_JianJie.gameObject.SetActive(true);
        }
        public void ShowDesc(string desc)
        {
            m_DescText.text = desc;
            m_DescText.gameObject.SetActive(true);
        }

        public void ShowCombineTitle(string title)
        {
            m_CombineTitle.text = title;
            m_CombineTitle.gameObject.SetActive(true);
            m_bg_HeCheng.gameObject.SetActive(true);
        }

        public void ShowCombineDesc(string desc)
        {
            m_CombineText.text = desc;
            m_CombineText.gameObject.SetActive(true);
        }

        public void HideTitle()
        {
            m_NameText.gameObject.SetActive(false);
            m_bg_JianJie.gameObject.SetActive(false);



        }
        public void HideDesc()
        {
            m_DescText.gameObject.SetActive(false);
        }


        public void HideCombineTitle()
        {
            m_CombineTitle.gameObject.SetActive(false);
            m_bg_HeCheng.gameObject.SetActive(false);

        }

        public void HideCombineText()
        {
            m_CombineText.gameObject.SetActive(false);
        }



        public void ShowCase(CaseContent content)
        {
            if (content == null || (content != null && content.Entity == null)) return;


        }




    }
}